<?php
header("Content-Type: text/html");
header("charset: utf-8");
include_once("_common.php");

$wr = sql_fetch(" select * from $bo_table where wr_id = '$wr_id' ");

$returnVal = "";

if ($wr['wr_id']) {

// 원글에 코멘트수 증가 & 마지막 시간 반영
sql_query(" update $bo_table set wr_comment = wr_comment - 1, wr_last = now() where wr_id = '$parent_wr_id' ");
// 댓글삭제
sql_query(" delete from  $bo_table where wr_id = '$wr_id' and wr_is_comment = 1 ");

$wr = sql_query(" select *, (select case when (a.mb_icon is null or a.mb_icon = '') and mb_sex='F' then '/img/product/icon_people1.gif' when (a.mb_icon is null or a.mb_icon = '') then '/img/product/icon_people.gif' else a.mb_icon end from g4_member a where a.mb_id = b.mb_id) as mb_icon, (select count(*) from $bo_table a where b.wr_id = a.family) as family_cnt from $bo_table b where wr_parent = '$parent_wr_id' and wr_is_comment = 1 order by orderby desc ");

$wr_id = $parent_wr_id;
$returnVal .= "<table>";

for ($i=0; $row=sql_fetch_array($wr); $i++){
	$returnVal .= "\n	<tr>";
	$returnVal .= "\n		<td>";
	if(intval($row['step']) > 1){
		//for($k=1; $k<intval($row['step']); $k++){
			$returnVal .= "\n	&nbsp;&nbsp;&nbsp;&nbsp;";
		//}
		$returnVal .= "\n		<img src=\"../img/product/icon_re.gif\" width=\"17\" height=\"11\" hspace=\"3\" vspace=\"3\" align=\"absmiddle\" />";
	}
	
	$returnVal .= "\n			".$row['wr_name']."<img src=\"{$row['mb_icon']}\" width=\"22\" height=\"23\" align=\"absmiddle\" />&nbsp;&nbsp;&nbsp;&nbsp;".$row['wr_content'];
	if($member['mb_id']){
	$returnVal .= "\n			&nbsp;&nbsp;<img src=\"../img/product/bt_re.gif\" style=\"cursor:pointer;\" onclick=\"javascript:showContent('".$wr_id."_".$row['wr_id']."');\" width=\"40\" height=\"19\" vspace=\"2\" align=\"absmiddle\" />";
	}
	
	if($mb_id == $row['mb_id'] || $is_admin == "super" || $is_auth){
		$returnVal .= "\n			&nbsp;<img src=\"../img/product/bt_del.gif\" style=\"cursor:pointer;\" onclick=\"javascript:deleteContent('".$wr_id."', '".$row['wr_id']."', '".$row['step']."', '".$row['family_cnt']."');\" width=\"40\" height=\"19\" vspace=\"2\" align=\"absmiddle\" />";
	}
	
	$returnVal .= "\n		</td>";
	$returnVal .= "\n	</tr>";
	$returnVal .= "\n	<tr id=\"".$wr_id."_".$row['wr_id']."_content\" style=\"display:none\">";
	$returnVal .= "\n		<td>";
	$returnVal .= "\n			<input type=\"text\" name=\"re_content_".$wr_id."_".$row['wr_id']."\" id=\"re_content_".$wr_id."_".$row['wr_id']."\" size=\"110\" />";
	$returnVal .= "\n			<img src=\"../img/product/bt_enter.gif\" style=\"cursor:pointer;\" onclick=\"javascript:writeContent('".$wr_id."', '".$row['wr_id']."', '".$row['orderby']."', '".$row['step']."');\" width=\"46\" height=\"22\" align=\"absmiddle\" />";
	$returnVal .= "\n		</td>";
	$returnVal .= "\n	</tr>";
}
$returnVal .= "</table>";
}

echo $returnVal;

?>